<?php
include $_SERVER['DOCUMENT_ROOT'].'/lib/Epi/Epi.php';
//Epi::setPath('base', $_SERVER['DOCUMENT_ROOT'].'/lib/Epi');
//Epi::setSetting('exceptions', true);

Epi::init('api');

//getApi()->get('/', array('api', 'def'),EpiApi::external);
getApi()->get('/version.json', array('api','ver'),EpiApi::external);
getApi()->get('/user.json', array('api','user'),EpiApi::external);
getRoute()->get('/user', array('site','users'));

$tst=getRoute()->run();
//echo $tst;

class api{
  function def(){
	  return '/version.json,/user.json';
	}
	function ver(){
	  return '0.1';
	}
	function user(){
	  $users = array(
      array('username' => 'John'),
      array('username' => 'Paul'),
      array('username' => 'Andru')
    );
    return $users;
	}
}

class site{
	function users(){
	  $users = getApi()->invoke('/user.json');
    $res= '<ul>';
    foreach($users as $user)	$res.= "<li>{$user['username']}</li>";
    $res.='</ul>';
    echo $res;
	}
}
?>